package com.cy.pj.goods.dao.impl;

import com.cy.pj.goods.dao.GoodsDao;
import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class GoodsDaoImpl implements GoodsDao {
    @Autowired
    private SqlSession sqlSession;
    @Override
    public List<Goods> findGoods() {
        //System.out.println("namespace="+namespace);
        //Mybatis数据访问实现
        String namespace = this.getClass().getInterfaces()[0].getName();
        System.out.println("namespace="+namespace);
        String elementId=Thread.currentThread().getStackTrace()[1].getMethodName();
        System.out.println("elementId="+elementId);
        String statement = namespace+"."+elementId;//映射文件的namespace+elementId
        List<Goods> list = sqlSession.selectList(statement);
        return list;
    }
}
